Now let's work on the condition where if you die in your battle royale, you get teleported back here.
I'm going to go to my battle royale place.
There we go.
And let's go to our asset manager.
If we go to view as the asset manager and open places, I need to get the original place ID so we're
in the battle royale.
Let's click on my zombie game, right click copy ID to clipboard, and then I'm going to go to my server
script service.
Hit the plus, add a script.
There we go.
And I'm going to call this battle Manager Battle MGR.
I'll go ahead and close this.
Hopefully I still have my ID in the buffer.
I'll do a variable for the ID.
I'm going to call it home ID.
So when we go home, I'm going to make it a string.
It should work as an integer or a string, but I always pass it as a string.
That's why there's speech quotes, right?
Because of the string.
All right.
What else do I need?
I need my teleport service because we're going to go back.
So I'll do ts equals game.
Get service.
Teleport service.
And then I'm going to do a function.
I'm going to say local function, add player to game and I'll pass the player in.
Let me get the player and then I'm going to get the character added event.
Connect that to an anonymous function.
The character will get passed in as a parameter there.
I'll just call it Char.
Then I'm going to get the humanoid from the char the character.
So char colon wait for child humanoid and on the humanoid I'm going to get the died event.
So let's do that.
Let's say Hume Dot died.
COLON And then connect that to a function.
New parameters will get passed in.
I'll get the teleport service colon and then we'll teleport.
Just go ahead and get the home ID, home ID, and we'll pass the player back.
And we're going to call this when the player added event fires for the game.
So I'm going to say game dot players, dot player added colon connect, add player to game and get rid
of those two extra parentheses at Roblox likes to add.
Now when we play our game, we die.
We should get teleported back when we're in our battle royale back to our home land.
Let's go ahead and save this off file.
Publish to Roblox.
Now, remember, we have to test it in the player.
We can't use Roblox studio, so we'll go to create.
There's my experience.
Boom Zombie game view on Roblox and we'll hit play.
Then I'll pause the video while it's loading up.
All right, here we go.
I'll accept.
And then I'm going to pause the video until I show up in my battle royale world.
Here we go.
And we're in the battle royale world.
Maybe I could bring up the console here.
Let's see.
Settings Developer console.
Just in case anything weird happens.
We don't have any messages being printed out.
I'm going to kill myself by resetting the character.
Hit that thing and we'll set reset character.
Ah, Move this down.
Reset.
Oh, we died.
Are.
And we went back.
So notice we died.
We respond in the arena and then we came back.
So what I think I'm going to do is increase the spawn time in the battle royale.
Let's go to the other world.
I'm going to turn this off first, so we'll just go ahead and leave.
And we're in the battle royale place.
So when I played the game, I timed the respawn time.
I think I said spawn time, but it's the respawn time.
It's almost eight seconds to do the teleporting.
So let's go to our player service and change our respawn time.
There we go.
Respawn eight seconds.
It's going to take you some time.
If you die in the battle royale.
Let's go ahead and hit publish to Roblox.
I'm going to save the other one too, and we'll go publish to Roblox.
Let's bring up our game.
Play it.
Go over here, initiate the battle, and then I'll pause it again so you don't have to wait.
Except.
All right.
I am in my battle royale.
Let's go ahead and kill ourselves off.
Reset character.
Boom.
And let's see.
And we are back.
I think that'll work.
And I kind of like the longer respawn time too, because then we can put like a little killed by guy
up, right?
While you're waiting for our teleport to go back to the home world.
That's pretty cool.
Let's go ahead and work on the winning of the game.